package logic

import (
	"B/shenzhou_srv/model/mysql"
	"context"

	"B/shenzhou_srv/internal/svc"
	"B/shenzhou_srv/shenzhou"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderListLogic {
	return &OrderListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderListLogic) OrderList(in *shenzhou.OrderListRequest) (*shenzhou.OrderListResponse, error) {
	// todo: add your logic here and delete this line
	var o mysql.Order
	list := o.List()

	var user []*shenzhou.OrderList
	for _, u2 := range list {
		user = append(user, &shenzhou.OrderList{
			UserId:  int64(u2.UserId),
			OrderSn: u2.OrderSn,
			Amount:  float32(u2.Amount),
			Payment: u2.Payment,
			Status:  u2.Status,
		})
	}
	return &shenzhou.OrderListResponse{List: user}, nil
}
